//
//  CYMine_MyCollectionAllTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/29.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYMine_MyCollectionAllTableViewCell.h"

@implementation CYMine_MyCollectionAllTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.headImageView.layer.cornerRadius = self.headImageView.frame.size.height / 2;
    self.headImageView.layer.masksToBounds = YES;
}

- (void)setModel:(CYProjectModel *)model{
    _model = model;
    self.upImageViewWidthConstraint.constant = 50;
    self.bottomImageViewWidthConstraint.constant = 50;
    self.upImageView.hidden = YES;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
    }];
    self.nicknameLabel.text = model.nickname;
    self.timeLabel.text = model.collect_time;
    self.contentLabel.text = model.title;
    
    if ([model.type integerValue] == 7) {
        NSArray *images = [model.images componentsSeparatedByString:@","];
        if (images.count > 0) {
            [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:[images firstObject]] placeholderImage:[UIImage imageNamed:@"wd_gezl_lj"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
            }];
        }
        
    }else if ([model.type integerValue] == 3){
        
    }else if ([model.type integerValue] == 4){
        self.upImageViewWidthConstraint.constant = 0;
        self.bottomImageViewWidthConstraint.constant = 0;
        
    }else if ([model.type integerValue] == 28){
        self.upImageView.hidden = YES;
        [self.bottomImageView sd_setImageWithURL:[NSURL URLWithString:model.cover_url] placeholderImage:[UIImage imageNamed:@"wd_gezl_lj"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
            self.upImageView.hidden = NO;
        }];

    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
